<template>
    <!-- pages/record/index.wxml -->
    <view class="record">
        <view class="records" v-if="list.length > 0">
            <view class="tab record-list" v-for="(item, key) in list" :key="item.key">
                <view class="record-title">
                    <view class="record-title-l">{{ item.createTime }}</view>
                    <view class="record-title-r">{{ item.failureFlagtype }}</view>
                </view>

                <view class="record-body">
                    <view class="record-b">
                        <view class="record-b-l">
                            <image src="../../static/assets/img/re1.png" mode="widthFix"></image>
                            <view class="record-b-l-t1">银行卡</view>
                            <view class="record-b-l-t2">{{ item.bankAccount }}</view>
                        </view>
                        <view class="record-b-l">
                            <image src="../../static/assets/img/re2.png" mode="widthFix"></image>
                            <view class="record-b-l-t1">开户行</view>
                            <view class="record-b-l-t2">{{ item.bankAccount }}</view>
                        </view>
                        <view class="record-b-l">
                            <image src="../../static/assets/img/re3.png" mode="widthFix"></image>
                            <view class="record-b-l-t1">持卡人</view>
                            <view class="record-b-l-t2">{{ item.name }}</view>
                        </view>
                    </view>
                    <view class="record-b-r">
                        <view class="record-b-r-t1">+{{ item.withdrawalAmount }}元</view>
                        <view v-if="item.withdrawState == -1 || item.withdrawState == 0" class="record-b-r-t2w">
                            {{ item.withdrawStatetype }}
                        </view>
                        <view v-else class="record-b-r-t2">{{ item.withdrawStatetype }}</view>
                    </view>
                </view>
            </view>
        </view>
        <view v-else>
            <view class="nopark">
                <image src="../../static/assets/img/empty.png"></image>
            </view>
            <view class="nopark-text">暂无数据</view>
        </view>
    </view>
</template>

<script>
// pages/record/index.js
import util from './../../utils/util.js';
import api from './../../utils/api.js';
export default {
    data() {
        return {
            list: []
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function (options) {
        this.getWithdrawlist();
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {},
    /**
     * 页面上拉触底事件的处理函数
     */
    // onShareAppMessage: function() {}
    onReachBottom: function () {},
    /**
     * 用户点击右上角分享
     */ methods: {
        getWithdrawlist() {
            const param = {
                unionId: uni.getStorageSync('unionId')
            };
            util.request(api.Withdrawlist, param, 'POST').then((res) => {
                if (res.code == 0) {
                    if (res.data.content && res.data.content.length > 0) {
                        res.data.content.forEach((e) => {
                            if (e.withdrawState == -1) {
                                e.withdrawStatetype = '未打款';
                            } else if (e.withdrawState == 1) {
                                e.withdrawStatetype = '已打款';
                            }

                            if (e.failureFlag == 0) {
                                e.failureFlagtype = '处理中';
                            } else if (e.failureFlag == -1) {
                                e.failureFlagtype = '打款失败';
                            } else {
                                e.failureFlagtype = '';
                            }
                        });
                        this.setData({
                            list: res.data.content
                        });
                    }
                }
            });
        }
    }
};
</script>
<style>
@import './index.css';
</style>
